import {createRouter, createWebHashHistory} from 'vue-router'
import Login from '../views/login.vue';
import Register from '../views/register/register.vue';
import AdminIndex from '../layout/index.vue'
import NotFind from '../views/404.vue'
const routers = [
    { path: "/", redirect: "/login" },
    {
        path: "/login",
        name: "login",
        component: Login
    },
    {
        path: "/register",
        name: "register",
        component: Register
        // meta: {
        //     requiredLogin: true
        // }
    },
    {
        path: "/index",
        name: "index",
        component: AdminIndex
    }
]


const router = createRouter({
    mode: 'history',
    history: createWebHashHistory(),
    routes: routers
})


//路由导航守卫
// router.beforeEach(((to, from, next) => {
//     if (to.meta.requiredLogin && !store.state.user.isLogin) {
//         next({name: '/login'})
//     } else {
//         next()
//     }
// }))
export default router;